<%@ page language="java" import="java.util.*,com.beans.*,com.dao.*" pageEncoding="UTF-8"%> 
<%
String path = request.getContextPath();  
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
             
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> 
<html>
  <head>
    <base href="<%=basePath%>"> 
    
    <title>My JSP 'index.jsp' starting page</title>
    <link rel="stylesheet" type="text/css" href="css/maintable.css" ></link>
    <link rel="stylesheet" type="text/css" href="css/edittable.css"  ></link>  
		<link rel="stylesheet" type="text/css" href="css/validate.css"  ></link>  
		<script type="text/javascript"  src="js/jquery-1.8.0.js"></script>
    		<script type="text/javascript" src="js/My97DatePicker/WdatePicker.js"></script>
   <script>
   function delAll(pageIndex){
		if($("input[name=ck_id]:checked").size()==0)
			alert("请至少选一项!");
		else{
			if(confirm('确定要删除所选项吗')){
				$('form').attr('action',"MemberServlet.do?flag=delAll&pageIndex="+pageIndex);
				form1.submit();
			}
		}
	}
	function  lock(id,pageIndex){
		if(confirm('确定要删除吗')){//所有删除尽量都用表单提交的形式要不然只能把所有数据都放到href里面
			$('form').attr('action',"MemberServlet.do?flag=delete&id="+id+"&pageIndex="+pageIndex);
			form1.submit();
	}
}
   
	function jump (max){
		var pageIndex=document.getElementById("pageIndex").value
		if(pageIndex>0&&pageIndex<=max){
			window.location.href="MemberServlet.do?flag=manage&pageIndex="+pageIndex+"&memberNo="+get('memberNo').value+"&startDate="+get('startDate').value+"&endDate="+get('endDate').value;
		}
		else{
			alert("输入页码有误,请重新输入");
		}
	}
	function get(id){
    	return document.getElementById(id);
    }
	 function c(name){
		 get(name).href+=("&memberNo="+get('memberNo').value+"&startDate="+get('startDate').value+"&endDate="+get('endDate').value);
	    }
	$(function(){
		
		$("#ch_checkall,#top_ch_checkall").click(function(){
			if(this.checked){
				$("input[name=ck_id]").attr("checked","checked");
			}else{
				$("input[name=ck_id]").removeAttr("checked");
			}		
		});
				
		$("table tr").mouseover(function(){
			$(this).css("background","#D3EAEF");
			$(this).siblings().css("background","white");
		});
	});
		 </script>
     <style>
    .div_tools{
    		width:99.5%; 
			height:28px;
			background:#D3EAEF;
			margin:0px auto;
			margin-top:5px;
			margin-bottom:5px;
			font-size:12px;
			position:relative;	 
			
    	}
    	
    	.div_tools select{
    		height:22px;
    		font-size:12px;
			margin-top:3px;
    	}
    	
    	
    	#img_div{
    		display:none;
    		position: absolute;
    	}
    </style>
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	
	
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
  </head>
  
  <body>
   <div class ="div_title">
						<div class="div_titlename"> <img src="images/san_jiao.gif" ><span>商品列表</span></div>
						<div class="div_titleoper">
							<input type="checkbox" id="top_ch_checkall"/> 全选 <a href="admin_add.jsp"> <img src="images/add.gif"/>添加 </a> <a href="javascript:delAll(${page.pageIndex})"><img src="images/del.gif"/>删除</a> </div>
				 </div>
				 <form action="MemberServlet.do?flag=manage"  name="form1" method="post">
				 	 <div class ="div_tools">
				 	   &nbsp; &nbsp;
				 
				  &nbsp; &nbsp;
				  会员账号: <input id=memberNo name=memberNo  value="${param.memberNo }">
				   注册日期从 : <input id=startDate name=startDate onclick="WdatePicker()" value="${param.startDate }">
				 到: <input id=endDate name=endDate onclick="WdatePicker()"  value="${param.endDate }">
				
				  <button>查询</button> 
			   </div>
				 <table class="main_table" >
				       <tr>
				 				<th width="4%"><input type="checkbox" id="ch_checkall"  /></th>	<th width="13%">账号</th> 	<th width="13%">姓名</th>	<th width="13%"> 电话</th>  <th width="13%">邮箱</th> 	<th width="13%">注册日期</th> <th width="13%">会员等级</th><th width="15%">操作</th> 
				 		</tr>
				 		
				 				<c:forEach var="member" items="${memberList }">
				 		<tr>
				 			<td>
				 					<input type="checkbox" name="ck_id" value="${member.id }" /> 
				 				</td>
				 				<td>${member.memberNo }</td>
				 				<td>${member.memberName}</td>	
				 				<td>${member.phone}</td>
				 				<td>${member.email }</td>
				 				<td>${member.registerDate}</td>	
				 				<td>${member.memberLevel }</td>
				 				<td>
								    <a href="member/member_see.jsp?id=${member.id }" >查看</a> | 
					 			    <a href="javascript:lock(${member.id},${page.pageIndex})">删除</a> 
				 				</td>
				 		</tr>
				 		</c:forEach>
				 		

				   		 
				 	
				</table>
				</form>
				
			<div class="div_page" >
					  <div class="div_page_left">    共有 <label>${page.rowCount}</label> 条记录，当前第 <label>${page.pageIndex}</label> 页，共 <label>${page.pageCount }</label> 页	</div>		
					  <div class="div_page_right" >
					  <c:choose> 	 
					  			<c:when test="${page.hasPre}">
					  			 <a id="sy" href="MemberServlet.do?flag=manage&pageIndex=1" onclick=" c('sy')">首页</a>
				  	 			 <a id="syy" href="MemberServlet.do?flag=manage&pageIndex=${page.pageIndex-1}"  onclick=" c('syy')">上一页</a>
					  			 </c:when>
					  			 <c:otherwise>
									首页
									上一页
								 </c:otherwise>
								 </c:choose>
								 <c:choose> 	
								 <c:when test="${page.hasNext}">
					  			 <a id="xyy" href="MemberServlet.do?flag=manage&pageIndex=${page.pageIndex+1}" onclick=" c('xyy')">下一页</a>
					  			 <a id="wy" href="MemberServlet.do?flag=manage&pageIndex=${page.pageCount }"  onclick=" c('wy')">尾页</a>
				  	 		   	 </c:when>
								 <c:otherwise>
									下一页
									尾页
								 </c:otherwise>
								 </c:choose>
					  	  <button onclick=jump(${page.pageCount})>转到</button>
					  	 <input type="text" name="pageIndex" id="pageIndex" value="${page.pageIndex}" /> 页
					  	
					   </div>	
				</div>
				<script>
				var msg='${msg}';
				if(msg!=''){
					alert(msg);
				}
				</script>
  </body>
</html>